]> dgit.raspbian.org Git - ostree.git/commitdiff
tests: Fix "remote:branch" test to use ostree_parse_refspec
authorJoseph Marrero Corchado <jmarrero@redhat.com>
Mon, 29 Jun 2026 19:22:19 +0000 (15:22 -0400)
committerJoseph Marrero Corchado <jmarrero@redhat.com>
Mon, 29 Jun 2026 19:22:19 +0000 (15:22 -0400)
ostree_validate_rev() validates bare ref names and does not accept
the "remote:ref" refspec syntax — the colon is not part of the
OSTREE_REF_REGEXP regex. The "remote:branch" form is a refspec,
which is parsed by ostree_parse_refspec().

Replace the incorrect ostree_validate_rev() call with
ostree_parse_refspec() and verify the parsed remote and ref
components, preserving the original test intent.

Fixes: ac10a27d ("pull: Fix GLib assertion crash on invalid UTF-8 ref names")
tests/test-validate-utf8.c

index 4aa07cfc8a0256fade48bd11d345c2569ca3961a..9f84e6bfecf1469986a9ed4089558af79562d7ef 100644 (file)
@@ -42,9 +42,17 @@ test_valid_utf8_refs (void)
   g_assert_true (ostree_validate_rev ("my.branch_name", &error));
   g_assert_no_error (error);
 
-  /* Valid ref with remote */
-  g_assert_true (ostree_validate_rev ("remote:branch", &error));
-  g_assert_no_error (error);
+  /* Valid refspec with remote: "remote:branch" is a refspec, not a bare ref.
+   * ostree_validate_rev() only validates bare ref names; use
+   * ostree_parse_refspec() for the "remote:ref" form. */
+  {
+    g_autofree char *remote = NULL;
+    g_autofree char *ref = NULL;
+    g_assert_true (ostree_parse_refspec ("remote:branch", &remote, &ref, &error));
+    g_assert_no_error (error);
+    g_assert_cmpstr (remote, ==, "remote");
+    g_assert_cmpstr (ref, ==, "branch");
+  }
 
   /* Valid ref with slashes */
   g_assert_true (ostree_validate_rev ("path/to/branch", &error));